package com.sunlands.qdcy.tongzhuo.repository;

import com.sunlands.qdcy.tongzhuo.model.UserDiaryReplyDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Repository
public interface UserDiaryReplyRepository extends JpaRepository<UserDiaryReplyDO, Long> ,JpaSpecificationExecutor<UserDiaryReplyDO> {

    Long countByCommentId(Long commentId);

    Long countByDiaryId(Long diaryId);

    List<UserDiaryReplyDO> findByCommentId(Long commentId);

    @Transactional
    @Modifying
    @Query(value = "update tz_user_diary_reply set status = ?1 where id=?2", nativeQuery = true)
    int updateStatusById(Integer status, Long id);

}
